# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
    File Name:  range
    Author   :  wanwei1029
    Date     :  2018/3/10
    Desc     :
------------------------------------------------------------------------------
主要看range和np.arrange()的区别
range的原型为：range(start,stop,[,step]),返回一个range object，可迭代
      start默认从0开始，range(5)等同于range(0,5).
      stop 计数到stop结束，但不包括stop.
      step 步长，默认为1，必须为整数，否则会报错
"""
import math
import samp.samp_logging as sl

logger = sl.get_logger('range')


def samp():
    """
    """
    start = 2
    stop = 10
    step = 2
    logger.info("range({0})={1}".format(stop,range(stop)))
    print_range(range(stop))
    logger.info("range({0},{1})={2}".format(start,stop, range(start,stop)))
    print_range(range(start,stop))


def print_range( rangeobj ):
    for obj in rangeobj:
        logger.info(obj)

def slice_demo():
    data = list(range(1, 94))
    print(data)
    split_num = 5
    print(len(data)/split_num)
    split_size = math.ceil(len(data)/split_num)
    print(split_size)
    result_list = list()
    for index in range(split_num):
        tmp_data = data[index*split_size:(index+1)*split_size]
        result_list.append(tmp_data)
    for data in result_list:
        print(data)



if __name__ == '__main__':
    test_method = "slice_demo"
    if test_method == "samp":
        samp()
    elif test_method == "slice_demo":
        slice_demo()

